home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / DJ111M2.ZIP / docs / djgpp / libc-i-m.tex < prev    next >
Text File  |  1994-01-08  |  28KB  |  1,220 lines

  1. @c ----------------------------------------------------------------------
  2. @node index, initstate, htons, Alphabetical List
  3.  
  4. @heading @code{index}
  5. @subheading Syntax
  6.  
  7. @example
  8. #include <strings.h>
  9.  
  10. char *index(const char *string, int ch);
  11. @end example
  12.  
  13. @subheading Description
  14.  
  15. Returns a pointer to the first occurrence of @var{ch} in @var{string}. 
  16. Note that the @code{NULL} character counts, so if you pass zero as
  17. @var{ch} you'll get a pointer to the end of the string back. 
  18.  
  19. @subheading Return Value
  20.  
  21. A pointer to the character, or @code{NULL} if it wasn't found.
  22.  
  23. @subheading Example
  24.  
  25. @example
  26. if (index(path, '*'))
  27.   do_wildcards(path);
  28. @end example
  29.  
  30. @c ----------------------------------------------------------------------
  31. @node initstate, insque, index, Alphabetical List
  32.  
  33. @heading @code{initstate}
  34. @subheading Syntax
  35.  
  36. @example
  37. #include <std.h>
  38.  
  39. char *initstate(unsigned int seed, char *state, int n);
  40. @end example
  41.  
  42. @subheading Description
  43.  
  44. This function fully initializes the random number generator
  45. (@xref{random}).  For more information on the random number generator,
  46. consult the source code @file{libsrc/c/gen/random.c}. 
  47.  
  48. @subheading Return Value
  49.  
  50. A pointer to the old state.
  51.  
  52. @c ----------------------------------------------------------------------
  53. @node insque, int86, initstate, Alphabetical List
  54.  
  55. @heading @code{insque}
  56. @subheading Syntax
  57.  
  58. @example
  59. void insque(struct vaxque *elem, struct vaxque *prev);
  60. @end example
  61.  
  62. @subheading Description
  63.  
  64. Given a queue of elements derived from this structure:
  65.  
  66. @example
  67. struct vaxque @{
  68.   struct vaxque *vq_next;
  69.   struct vaxque *vq_prev;
  70. @};
  71. @end example
  72.  
  73. This function inserts a new element @var{elem} in the queue after the
  74. element specified (@var{prev}).  This function emulates the VAX
  75. @code{insque} opcode.  @xref{remque}
  76.  
  77. @subheading Return Value
  78.  
  79. None.
  80.  
  81. @c ----------------------------------------------------------------------
  82. @node int86, int86x, insque, Alphabetical List
  83.  
  84. @heading @code{int86}
  85. @subheading Syntax
  86.  
  87. @example
  88. #include <dos.h>
  89.  
  90. int int86(int ivec, union REGS *in, union REGS *out);
  91. @end example
  92.  
  93. @subheading Description
  94.  
  95. This function is just like @code{int86x} (@xref{int86x}) except that
  96. suitable default values are used for the segment registers. 
  97.  
  98. @subheading Return Value
  99.  
  100. The returned value of @code{EAX}. 
  101.  
  102. @subheading Example
  103.  
  104. @example
  105. union REGS r;
  106. r.x.ax = 0x0100;
  107. r.h.dl = 'c';
  108. int86(0x21, &r, &r);
  109. @end example
  110.  
  111. @c ----------------------------------------------------------------------
  112. @node int86x, intdos, int86, Alphabetical List
  113.  
  114. @heading @code{int86x}
  115. @subheading Syntax
  116.  
  117. @example
  118. #include <dos.h>
  119.  
  120. int int86x(int ivec, union REGS *in, union REGS *out, struct SREGS *seg);
  121. @end example
  122.  
  123. @subheading Description
  124.  
  125. This function simulates a software interrupt.  Note that, unlike the
  126. @code{_go32_dpmi_*} functions, requests that go through @code{int86x}
  127. and similar functions are normally processed by go32 to make it easier
  128. for the programmer to use these functions.  For example, if a particular
  129. routine takes a pointer in @code{ES:BX}, go32 expects you to put a
  130. virtual pointer in @code{EBX} and it ignores @code{ES}.  This is mostly
  131. because segments aren't used in protected mode the way they are in real
  132. mode, so go32 takes care of the conversion for you - and it knows what
  133. your segment selectors are anyway. 
  134.  
  135. When the interrupt is invoked, the CPU registers are copied from
  136. @var{in}.  After the interrupt, the CPU registers are copied to
  137. @var{out}.  In addition, the segment registers are loaded from @var{seg}
  138. and afterwards stored back into @var{seg}. 
  139.  
  140. @xref{int86} @xref{intdos} @xref{bdos}
  141.  
  142. @subheading Return Value
  143.  
  144. The value of @code{EAX} is returned.
  145.  
  146. @subheading Example
  147.  
  148. @example
  149. union REGS r;
  150. struct SREGS s;
  151. r.h.ah = 0x31;
  152. r.h.dl = 'c';
  153. r.x.si = si_val;
  154. s.ds = ds_val;
  155. int86x(0x21, &r, &r, &s);
  156. @end example
  157.  
  158. @c ----------------------------------------------------------------------
  159. @node intdos, intdosx, int86x, Alphabetical List
  160.  
  161. @heading @code{intdos}
  162. @subheading Syntax
  163.  
  164. @example
  165. #include <dos.h>
  166.  
  167. int intdos(union REGS *in, union REGS *out);
  168. @end example
  169.  
  170. @subheading Description
  171.  
  172. This function is just like @code{int86x} (@xref{int86x}) except that
  173. suitable default values are used for the segment registers and the
  174. interrupt vector is 0x21. 
  175.  
  176. @subheading Return Value
  177.  
  178. @code{EAX}
  179.  
  180. @c ----------------------------------------------------------------------
  181. @node intdosx, _iob, intdos, Alphabetical List
  182.  
  183. @heading @code{intdosx}
  184. @subheading Syntax
  185.  
  186. @example
  187. #include <dos.h>
  188.  
  189. int intdosx(union REGS *in, union REGS *out, struct SREGS *s);
  190. @end example
  191.  
  192. @subheading Description
  193.  
  194. This function is just like @code{int86x} (@xref{int86x}) except that the
  195. interrupt vector is 0x21.
  196.  
  197. @subheading Return Value
  198.  
  199. @code{EAX}
  200.  
  201. @c ----------------------------------------------------------------------
  202. @node _iob, isalnum, intdosx, Alphabetical List
  203.  
  204. @heading @code{_iob}
  205.  
  206. @subheading Description
  207.  
  208. This is an internal variable used to keep track of open @code{FILE*}
  209. files. 
  210.  
  211. @c ----------------------------------------------------------------------
  212. @node isalnum, isalpha, _iob, Alphabetical List
  213.  
  214. @heading @code{isalnum}
  215. @subheading Syntax
  216.  
  217. @example
  218. #include <ctype.h>
  219.  
  220. int isalnum(int c);
  221. @end example
  222.  
  223. @subheading Description
  224.  
  225. Tells if @var{c} is any letter or digit.
  226.  
  227. @subheading Return Value
  228.  
  229. Nonzero if @var{c} is a letter or digit, else zero.
  230.  
  231. @subheading Example
  232.  
  233. @c ----------------------------------------------------------------------
  234. @node isalpha, isatty, isalnum, Alphabetical List
  235.  
  236. @heading @code{isalpha}
  237. @subheading Syntax
  238.  
  239. @example
  240. #include <ctype.h>
  241.  
  242. int isalpha(int c);
  243. @end example
  244.  
  245. @subheading Description
  246.  
  247. Tells if @var{c} is a letter.
  248.  
  249. @subheading Return Value
  250.  
  251. Nonzero if @var{c} is a letter, else zero.
  252.  
  253. @c ----------------------------------------------------------------------
  254. @node isatty, iscntrl, isalpha, Alphabetical List
  255.  
  256. @heading @code{isatty}
  257. @subheading Syntax
  258.  
  259. @example
  260. #include <osfcn.h>
  261.  
  262. int isatty(int fd);
  263. @end example
  264.  
  265. @subheading Description
  266.  
  267. Tells if the file descriptor refers to a physical device or a disk file.
  268.  
  269. @subheading Return Value
  270.  
  271. Nonzero if @var{fd} is a device, zero if it is a disk file.
  272.  
  273. @subheading Example
  274.  
  275. @example
  276. if (isatty(1))
  277.   fflush(stdout);
  278. @end example
  279.  
  280. @c ----------------------------------------------------------------------
  281. @node iscntrl, isdigit, isatty, Alphabetical List
  282.  
  283. @heading @code{iscntrl}
  284. @subheading Syntax
  285.  
  286. @example
  287. #include <ctype.h>
  288.  
  289. int iscntrl(int c);
  290. @end example
  291.  
  292. @subheading Description
  293.  
  294. Tells if @var{c} is a control character.
  295.  
  296. @subheading Return Value
  297.  
  298. Nonzero if @var{c} is a control character, else zero.
  299.  
  300. @c ----------------------------------------------------------------------
  301. @node isdigit, isgraph, iscntrl, Alphabetical List
  302.  
  303. @heading @code{isdigit}
  304. @subheading Syntax
  305.  
  306. @example
  307. #include <ctype.h>
  308.  
  309. int isdigit(int c);
  310. @end example
  311.  
  312. @subheading Description
  313.  
  314. Tells if @var{c} is a digit.
  315.  
  316. @subheading Return Value
  317.  
  318. Nonzero if @var{c} is a digit, else zero.
  319.  
  320. @c ----------------------------------------------------------------------
  321. @node isgraph, islower, isdigit, Alphabetical List
  322.  
  323. @heading @code{isgraph}
  324. @subheading Syntax
  325.  
  326. @example
  327. #include <ctype.h>
  328.  
  329. int isgraph(int c);
  330. @end example
  331.  
  332. @subheading Description
  333.  
  334. Tells if @var{c} is a visible printing character.  Space is not
  335. included. 
  336.  
  337. @subheading Return Value
  338.  
  339. Nonzero if @var{c} is a visible printing character, else zero.
  340.  
  341. @c ----------------------------------------------------------------------
  342. @node islower, isprint, isgraph, Alphabetical List
  343.  
  344. @heading @code{islower}
  345. @subheading Syntax
  346.  
  347. @example
  348. #include <ctype.h>
  349.  
  350. int islower(int c);
  351. @end example
  352.  
  353. @subheading Description
  354.  
  355. Tells if @var{c} is lower case or not.
  356.  
  357. @subheading Return Value
  358.  
  359. Nonzero if @var{c} is lower case, else zero.
  360.  
  361. @c ----------------------------------------------------------------------
  362. @node isprint, ispunct, islower, Alphabetical List
  363.  
  364. @heading @code{isprint}
  365. @subheading Syntax
  366.  
  367. @example
  368. #include <ctype.h>
  369.  
  370. int isprint(int c);
  371. @end example
  372.  
  373. @subheading Description
  374.  
  375. Tells if @var{c} is a printing character, which includes the space
  376. character.
  377.  
  378. @subheading Return Value
  379.  
  380. Nonzero if @var{c} is a printing character, else zero.
  381.  
  382. @c ----------------------------------------------------------------------
  383. @node ispunct, isspace, isprint, Alphabetical List
  384.  
  385. @heading @code{ispunct}
  386. @subheading Syntax
  387.  
  388. @example
  389. #include <ctype.h>
  390.  
  391. int ispunct(int c);
  392. @end example
  393.  
  394. @subheading Description
  395.  
  396. Tells if @var{c} is any printing character except space and those
  397. indicated by @code{isalnum}. 
  398.  
  399. @subheading Return Value
  400.  
  401. Nonzero if @var{c} is punctuation, else zero.
  402.  
  403. @c ----------------------------------------------------------------------
  404. @node isspace, isupper, ispunct, Alphabetical List
  405.  
  406. @heading @code{isspace}
  407. @subheading Syntax
  408.  
  409. @example
  410. #include <ctype.h>
  411.  
  412. int isspace(int c);
  413. @end example
  414.  
  415. @subheading Description
  416.  
  417. Tells if @var{c} is whitespace, that is, carriage return, newline, form
  418. feed, tab, vertical tab, or space.
  419.  
  420. @subheading Return Value
  421.  
  422. Nonzero if @var{c} is whitespace, else zero.
  423.  
  424. @c ----------------------------------------------------------------------
  425. @node isupper, isxdigit, isspace, Alphabetical List
  426.  
  427. @heading @code{isupper}
  428. @subheading Syntax
  429.  
  430. @example
  431. #include <ctype.h>
  432.  
  433. int isupper(int c);
  434. @end example
  435.  
  436. @subheading Description
  437.  
  438. Tells if @var{c} is an upper case character or not.
  439.  
  440. @subheading Return Value
  441.  
  442. Nonzero if @var{c} is upper case, else zero.
  443.  
  444. @c ----------------------------------------------------------------------
  445. @node isxdigit, kbhit, isupper, Alphabetical List
  446.  
  447. @heading @code{isxdigit}
  448. @subheading Syntax
  449.  
  450. @example
  451. #include <ctype.h>
  452.  
  453. int isxdigit(int c);
  454. @end example
  455.  
  456. @subheading Description
  457.  
  458. Tells if @var{c} is a valid hexidecimal digit or not.  This includes
  459. @code{[0-9a-fA-f]}. 
  460.  
  461. @subheading Return Value
  462.  
  463. Nonzero if @var{c} is a hex digit, else zero.
  464.  
  465. @c ----------------------------------------------------------------------
  466. @node kbhit, kill, isxdigit, Alphabetical List
  467.  
  468. @heading @code{kbhit}
  469. @subheading Syntax
  470.  
  471. @example
  472. #include <pc.h>
  473.  
  474. int kbhit(void);
  475. @end example
  476.  
  477. @subheading Description
  478.  
  479. If the user has hit a key, this function will detect it.  This function
  480. is very fast when there is no key waiting, so it may be used inside
  481. loops as needed. 
  482.  
  483. @subheading Return Value
  484.  
  485. Nonzero if a key has been hit, else zero.
  486.  
  487. @subheading Example
  488.  
  489. @example
  490. while (!kbhit())
  491.   do_stuff();
  492. @end example
  493.  
  494. @c ----------------------------------------------------------------------
  495. @node kill, labs, kbhit, Alphabetical List
  496.  
  497. @heading @code{kill}
  498.  
  499. @subheading Description
  500.  
  501. This function does nothing.  It exists to assist in porting Unix
  502. programs. 
  503.  
  504. @c ----------------------------------------------------------------------
  505. @node labs, ldexp, kill, Alphabetical List
  506.  
  507. @heading @code{labs}
  508. @subheading Syntax
  509.  
  510. @example
  511. #include <stdlib.h>
  512.  
  513. long labs(long x);
  514. @end example
  515.  
  516. @subheading Description
  517.  
  518. This function takes the absolute value of @var{x}.  @xref{abs}
  519.  
  520. @subheading Return Value
  521.  
  522. |@var{x}|
  523.  
  524. @c ----------------------------------------------------------------------
  525. @node ldexp, ldiv, labs, Alphabetical List
  526.  
  527. @heading @code{ldexp}
  528. @subheading Syntax
  529.  
  530. @example
  531. #include <math.h>
  532.  
  533. double ldexp(double val, int exp);
  534. @end example
  535.  
  536. @subheading Return Value
  537.  
  538. This function returns @var{val} * 2 ** @var{exp}.
  539.  
  540. @subheading Example
  541.  
  542. @example
  543. ldexp(3.5,4) == 3.5 * 16 == 56.0
  544. @end example
  545.  
  546. @c ----------------------------------------------------------------------
  547. @node ldiv, link, ldexp, Alphabetical List
  548.  
  549. @heading @code{ldiv}
  550. @subheading Syntax
  551.  
  552. @example
  553. #include <stdlib.h>
  554.  
  555. ldiv_t ldiv(long numerator, long denomonator);
  556. @end example
  557.  
  558. @subheading Description
  559.  
  560. Returns the quotient and remainder of the division @var{numberator}
  561. divided by @var{denomonator}.  The return type is as follows:
  562.  
  563. @example
  564. typedef struct @{
  565.   long quot;
  566.   long rem;
  567. @} ldiv_t;
  568. @end example
  569.  
  570. @subheading Return Value
  571.  
  572. The results of the division are returned.
  573.  
  574. @subheading Example
  575.  
  576. @example
  577. ldiv_t l = div(42, 3);
  578. printf("42 = %ld x 3 + %ld\n", l.quot, l.rem);
  579. @end example
  580.  
  581. @c ----------------------------------------------------------------------
  582. @node link, localtime, ldiv, Alphabetical List
  583.  
  584. @heading @code{link}
  585. @subheading Syntax
  586.  
  587. @example
  588. #include <osfcn.h>
  589.  
  590. int link(const char *exists, const char *new);
  591. @end example
  592.  
  593. @subheading Description
  594.  
  595. Because of limitations of MS-DOS, this function doesn't really link two
  596. files together.  However, it simulates a real @code{link} by copying the
  597. file at @var{exists} to @var{new}. 
  598.  
  599. @subheading Return Value
  600.  
  601. Zero on success, nonzero on failure.
  602.  
  603. @subheading Example
  604.  
  605. @example
  606. link("foo.c", "foo.bak");
  607. @end example
  608.  
  609. @c ----------------------------------------------------------------------
  610. @node localtime, lock, link, Alphabetical List
  611.  
  612. @heading @code{localtime}
  613. @subheading Syntax
  614.  
  615. @example
  616. #include <time.h>
  617.  
  618. struct tm *localtime(const time_t *tod);
  619. @end example
  620.  
  621. @subheading Description
  622.  
  623. Converts the time represented by @var{tod} into a structure, correcting
  624. for the local timezone.  @xref{gmtime}
  625.  
  626. @subheading Return Value
  627.  
  628. A pointer to a static structure which is overridden with each call. 
  629.  
  630. @c ----------------------------------------------------------------------
  631. @node lock, longjmp, localtime, Alphabetical List
  632.  
  633. @heading @code{lock}
  634. @subheading Syntax
  635.  
  636. @example
  637. #include <io.h>
  638.  
  639. int lock(int fd, long offset, long length);
  640. @end example
  641.  
  642. @subheading Description
  643. Locks a region in file @var{fd} using MS-DOS file sharing interface.
  644. The region of @var{length} bytes, starting from @var{offset}, will
  645. become entirely inaccessible to other processes. If multiple locks
  646. are used on a single file they must be non-overlapping. The lock
  647. must be removed before the file is closed.
  648.  
  649. This function will fail unless SHARE, or a network software
  650. providing similar interface, is installed. This function is
  651. compatible with Borland C++ function of the same name.
  652.  
  653. @xref{unlock}.
  654.  
  655. @subheading Return Value
  656. Zero if successful, nonzero if not.
  657.  
  658. @c ----------------------------------------------------------------------
  659. @node longjmp, longjmperror, lock, Alphabetical List
  660.  
  661. @heading @code{longjmp}
  662. @subheading Syntax
  663.  
  664. @example
  665. #include <setjmp.h>
  666.  
  667. void longjmp(jmp_buf env, int val);
  668. @end example
  669.  
  670. @subheading Description
  671.  
  672. This function reverts back to a CPU state that was stored in @var{env}
  673. by @code{setjmp} (@xref{setjmp}).  The state includes all CPU registers,
  674. so any variable in a register when @code{setjmp} was called will be
  675. preserved, and all else will be indeterminate.
  676.  
  677. The value passed as @var{val} will be the return value of @code{setjmp}
  678. when it resumes processing there.  If @var{val} is zero, the return
  679. value will be one. 
  680.  
  681. @subheading Return Value
  682.  
  683. This function does not return.
  684.  
  685. @subheading Example
  686.  
  687. @example
  688. jmp_buf j;
  689. if (setjmp(j))
  690.   return;
  691. do_something();
  692. longjmp(j);
  693. @end example
  694.  
  695. @c ----------------------------------------------------------------------
  696. @node longjmperror, lseek, longjmp, Alphabetical List
  697.  
  698. @heading @code{longjmperror}
  699. @subheading Syntax
  700.  
  701. @example
  702. void longjmperr(void);
  703. @end example
  704.  
  705. @subheading Description
  706.  
  707. This function is internal and is used by setjmp and longjmp when they
  708. detect an invalid longjmp request.
  709.  
  710. @subheading Return Value
  711.  
  712. None.
  713.  
  714. @c ----------------------------------------------------------------------
  715. @node lseek, __main, longjmperror, Alphabetical List
  716.  
  717. @heading @code{lseek}
  718. @subheading Syntax
  719.  
  720. @example
  721. #include <osfcn.h>
  722.  
  723. long lseek(nit fd, long offset, int whence);
  724. @end example
  725.  
  726. @subheading Description
  727.  
  728. This function moves the file pointer for @var{fd} according to
  729. @var{mode}:
  730.  
  731. @table @code
  732.  
  733. @item SEEK_SET
  734.  
  735. The file pointer is moved to the offset specified.
  736.  
  737. @item SEEK_CUR
  738.  
  739. The file pointer is moved relative to its current position.
  740.  
  741. @item SEEK_END
  742.  
  743. The file pointer is moved to a position @var{offset} bytes from the end
  744. of the file.  The offset is usually nonpositive in this case. 
  745.  
  746. @end table
  747.  
  748. @subheading Return Value
  749.  
  750. The new offset is returned.
  751.  
  752. @subheading Example
  753.  
  754. @example
  755. lseek(fd, 12, SEEK_CUR); /* skip 12 bytes */
  756. @end example
  757.  
  758. @c ----------------------------------------------------------------------
  759. @node __main, malloc, lseek, Alphabetical List
  760.  
  761. @heading @code{__main}
  762.  
  763. @subheading Description
  764.  
  765. This function is used internally to initialize the application, and
  766. should not be directly called by the programmer. 
  767.  
  768. @c ----------------------------------------------------------------------
  769. @node malloc, memccpy, __main, Alphabetical List
  770.  
  771. @heading @code{malloc}
  772. @subheading Syntax
  773.  
  774. @example
  775. #include <stdlib.h>
  776.  
  777. void *malloc(size_t size);
  778. @end example
  779.  
  780. @subheading Description
  781.  
  782. This function allocates a chunk of memory from the heap large enough to
  783. hold any object that is @var{size} bytes in length.  This memory must be
  784. returned to the heap with @code{free} (@xref{free}). 
  785.  
  786. @subheading Return Value
  787.  
  788. A pointer to the allocated memory, or @code{NULL} if there isn't enough
  789. free memory to satisfy the request. 
  790.  
  791. @subheading Example
  792.  
  793. @example
  794. char *c = (char *)malloc(100);
  795. @end example
  796.  
  797. @c ----------------------------------------------------------------------
  798. @node memccpy, memchr, malloc, Alphabetical List
  799.  
  800. @heading @code{memccpy}
  801. @subheading Syntax
  802.  
  803. @example
  804. #include <string.h>
  805.  
  806. void *memccpy(void *dest, const void *source, int ch, size_t num);
  807. @end example
  808.  
  809. @subheading Description
  810.  
  811. This function copies at most @var{num} bytes from @var{source} to
  812. @var{dest}, stopping if the character @var{ch} is copied. 
  813.  
  814. @subheading Return Value
  815.  
  816. A pointer to the character after @var{ch}, if it was found, else
  817. @code{NULL}. 
  818.  
  819. @subheading Example
  820.  
  821. @example
  822. char buf[20];
  823. memccpy(buf, "hello!", 'l', 20);
  824. @end example
  825.  
  826. @c ----------------------------------------------------------------------
  827. @node memchr, memcmp, memccpy, Alphabetical List
  828.  
  829. @heading @code{memchr}
  830. @subheading Syntax
  831.  
  832. @example
  833. void *memchr(const void *string, int ch, size_t num);
  834. @end example
  835.  
  836. @subheading Description
  837.  
  838. This function searches @var{num} bytes starting at @var{string}, looking
  839. for the first occurence of @var{ch}. 
  840.  
  841. @subheading Return Value
  842.  
  843. A pointer to the first match, or @code{NULL} if it wasn't found.
  844.  
  845. @subheading Example
  846.  
  847. @example
  848. if (memchr(path, '/', strlen(path))
  849.   do_slash();
  850. @end example
  851.  
  852. @c ----------------------------------------------------------------------
  853. @node memcmp, _memcpy, memchr, Alphabetical List
  854.  
  855. @heading @code{memcmp}
  856. @subheading Syntax
  857.  
  858. @example
  859. #include <string.h>
  860.  
  861. int memcmp(const void *s1, const void *s2, size_t num);
  862. @end example
  863.  
  864. @subheading Description
  865.  
  866. This function compares two regions of memory, at @var{s1} and @var{s2},
  867. for @var{num} bytes. 
  868.  
  869. @subheading Return Value
  870.  
  871. @table @asis
  872.  
  873. @item zero
  874.  
  875. s1 == s2
  876.  
  877. @item positive
  878.  
  879. s1 > s2
  880.  
  881. @item negative
  882.  
  883. s1 < s2
  884.  
  885. @end table
  886.  
  887. @c ----------------------------------------------------------------------
  888. @node _memcpy, memcpy, memcmp, Alphabetical List
  889.  
  890. @heading @code{_memcpy}
  891. @subheading Syntax
  892.  
  893. @example
  894. #include <string.h>
  895.  
  896. void *_memcpy(void *dest, const void *src, int num);
  897. @end example
  898.  
  899. @subheading Description
  900.  
  901. This function is just like @code{memcpy} (@xref{memcpy}), but it doesn't
  902. use the i386 @code{movs} opcode, in case the source and destination are
  903. on memory pages that can't reside in the system at the same time.  This
  904. is used primarily for screen to screen copies of the graphics screen, in
  905. case the two regions are in different graphics windows. 
  906.  
  907. @subheading Return Value
  908.  
  909. @var{dest}
  910.  
  911. @c ----------------------------------------------------------------------
  912. @node memcpy, memmove, _memcpy, Alphabetical List
  913.  
  914. @heading @code{memcpy}
  915. @subheading Syntax
  916.  
  917. @example
  918. #include <string.h>
  919.  
  920. void *memcpy(void *dest, const void *src, int num);
  921. @end example
  922.  
  923. @subheading Description
  924.  
  925. This function copies @var{num} bytes from @var{source} to @var{dest}. 
  926.  
  927. @subheading Return Value
  928.  
  929. @var{dest}
  930.  
  931. @subheading Example
  932.  
  933. @example
  934. memcpy(buffer, temp_buffer, BUF_MAX);
  935. @end example
  936.  
  937. @c ----------------------------------------------------------------------
  938. @node memmove, memset, memcpy, Alphabetical List
  939.  
  940. @heading @code{memmove}
  941. @subheading Syntax
  942.  
  943. @example
  944. #include <string.h>
  945.  
  946. void *memmove(void *dest, const void *source, int num);
  947. @end example
  948.  
  949. @subheading Description
  950.  
  951. This function copies @var{num} bytes from @var{source} to @var{dest}. 
  952. The copy is done in such a way that if the two regions overlap, the
  953. source is always read before that byte is changed by writing to the
  954. destination. 
  955.  
  956. @subheading Return Value
  957.  
  958. @var{dest}
  959.  
  960. @subheading Example
  961.  
  962. @example
  963. memmove(buf+1, buf, 99);
  964. memmove(buf, buf+1, 99);
  965. @end example
  966.  
  967. @c ----------------------------------------------------------------------
  968. @node memset, mkdir, memmove, Alphabetical List
  969.  
  970. @heading @code{memset}
  971. @subheading Syntax
  972.  
  973. @example
  974. #include <string.h>
  975.  
  976. void *memset(void *buffer, int ch, size_t num);
  977. @end example
  978.  
  979. @subheading Description
  980.  
  981. This function stores @var{num} copies of @var{ch}, starting at
  982. @var{buffer}.  This is often used to initialize objects to a known
  983. value. 
  984.  
  985. @subheading Return Value
  986.  
  987. @var{buffer}
  988.  
  989. @subheading Example
  990.  
  991. @example
  992. struct tm t;
  993. memset(&t, 0, sizeof(t));
  994. @end example
  995.  
  996. @c ----------------------------------------------------------------------
  997. @node mkdir, mkfifo, memset, Alphabetical List
  998.  
  999. @heading @code{mkdir}
  1000. @subheading Syntax
  1001.  
  1002. @example
  1003. #include <osfcn.h>
  1004.  
  1005. int mkdir(const char *path, int mode);
  1006. @end example
  1007.  
  1008. @subheading Description
  1009.  
  1010. This function creates a subdirectory.  The @var{mode} field is ignored
  1011. under MS-DOS. 
  1012.  
  1013. @subheading Return Value
  1014.  
  1015. Zero if the subdirectory was created, nonzero on failure.
  1016.  
  1017. @subheading Example
  1018.  
  1019. @example
  1020. mkdir("/usr/tmp");
  1021. @end example
  1022.  
  1023. @c ----------------------------------------------------------------------
  1024. @node mkfifo, mknod, mkdir, Alphabetical List
  1025.  
  1026. @heading @code{mkfifo}
  1027.  
  1028. @subheading Description
  1029.  
  1030. This function is provided only to assist in porting from Unix.  It
  1031. always returns an error condition. 
  1032.  
  1033. @c ----------------------------------------------------------------------
  1034. @node mknod, mkstemp, mkfifo, Alphabetical List
  1035.  
  1036. @heading @code{mknod}
  1037.  
  1038. @subheading Description
  1039.  
  1040. This function is provided only to assist in porting from Unix.  It
  1041. always returns an error condition. 
  1042.  
  1043. @c ----------------------------------------------------------------------
  1044. @node mkstemp, mktemp, mknod, Alphabetical List
  1045.  
  1046. @heading @code{mkstemp}
  1047. @subheading Syntax
  1048.  
  1049. @example
  1050. #include <stdio.h>
  1051.  
  1052. int mkstemp(char *template);
  1053. @end example
  1054.  
  1055. @subheading Description
  1056.  
  1057. @var{template} is a file specification that ends with six trailing
  1058. @code{X} characters.  This function replaces the @code{XXXXXX} with a
  1059. set of characters such that the resulting file name names a nonexisting
  1060. file.  It then creates and opens the file. 
  1061.  
  1062. Note that since MS-DOS is limited to eight characters for the file name,
  1063. and since none of the @code{X}'s get replaced by a dot, you can only
  1064. have two additional characters before the @code{X}'s. 
  1065.  
  1066. @subheading Return Value
  1067.  
  1068. The open file descriptor.
  1069.  
  1070. @subheading Example
  1071.  
  1072. @example
  1073. int fd = mkstemp("/tmp/ccXXXXXX");
  1074. @end example
  1075.  
  1076. @c ----------------------------------------------------------------------
  1077. @node mktemp, mktime, mkstemp, Alphabetical List
  1078.  
  1079. @heading @code{mktemp}
  1080. @subheading Syntax
  1081.  
  1082. @example
  1083. #include <stdio.h>
  1084.  
  1085. char *mktemp(char *template);
  1086. @end example
  1087.  
  1088. @subheading Description
  1089.  
  1090. @var{template} is a file specification that ends with six trailing
  1091. @code{X} characters.  This function replaces the @code{XXXXXX} with a
  1092. set of characters such that the resulting file name names a nonexisting
  1093. file.
  1094.  
  1095. Note that since MS-DOS is limited to eight characters for the file name,
  1096. and since none of the @code{X}'s get replaced by a dot, you can only
  1097. have two additional characters before the @code{X}'s. 
  1098.  
  1099. @subheading Return Value
  1100.  
  1101. The resulting filename.
  1102.  
  1103. @subheading Example
  1104.  
  1105. @example
  1106. char template[] = "/tmp/ccXXXXXX";
  1107. mktemp(template);
  1108. FILE *q = fopen(template, "w");
  1109. @end example
  1110.  
  1111. @c ----------------------------------------------------------------------
  1112. @node mktime, modf, mktemp, Alphabetical List
  1113.  
  1114. @heading @code{mktime}
  1115. @subheading Syntax
  1116.  
  1117. @example
  1118. #include <time.h>
  1119.  
  1120. time_t mktime(struct tm *tptr);
  1121. @end example
  1122.  
  1123. @subheading Description
  1124.  
  1125. This function converts a time structure into the number of seconds since
  1126. 00:00:00 GMT 1/1/1970.  It also attempts to normalize the fields of
  1127. @var{tptr}. 
  1128.  
  1129. @subheading Return Value
  1130.  
  1131. The resulting time, or -1 if the time in @var{tptr} cannot be described
  1132. in that format. 
  1133.  
  1134. @c ----------------------------------------------------------------------
  1135. @node modf, morecore, mktime, Alphabetical List
  1136.  
  1137. @heading @code{modf}
  1138. @subheading Syntax
  1139.  
  1140. @example
  1141. #include <math.h>
  1142.  
  1143. double modf(double x, double *pint);
  1144. @end example
  1145.  
  1146. @subheading Description
  1147.  
  1148. This function decomposes @var{x} into it's integer part (*@var{pint})
  1149. and it's fractional part (return value) such that the two have the same
  1150. sign and add up to @var{x}. 
  1151.  
  1152. @subheading Return Value
  1153.  
  1154. The fractional part.
  1155.  
  1156. @subheading Example
  1157.  
  1158. @example
  1159. double f, i;
  1160. f = modf(2.3, &i);
  1161. /* f == 0.3, i == 2.0 */
  1162. @end example
  1163.  
  1164. @c ----------------------------------------------------------------------
  1165. @node morecore, movedata, modf, Alphabetical List
  1166.  
  1167. @heading @code{morecore}
  1168.  
  1169. @subheading Description
  1170.  
  1171. This is an internal function used by @code{malloc} (@xref{malloc}). 
  1172.  
  1173. @c ----------------------------------------------------------------------
  1174. @node movedata, nlist, morecore, Alphabetical List
  1175.  
  1176. @heading @code{movedata}
  1177. @subheading Syntax
  1178.  
  1179. @example
  1180. #include <go32.h>
  1181.  
  1182. void movedata(unsigned source_selector, unsigned source_offset,
  1183.               unsigned dest_selector, unsigned dest_offset,
  1184.               size_t length);
  1185. @end example
  1186.  
  1187. @subheading Description
  1188.  
  1189. This function allows the caller to directly transfer information between
  1190. conventional and linear memory, and among each as well.  The selectors
  1191. passed are @emph{not} segment values like in DOS.  They are protected
  1192. mode selectors that can be obtained by the @code{_go32_my_ds} and
  1193. @code{_go32_conventional_mem_selector} functions (@xref{_go32_my_ds}
  1194. @xref{_go32_conventional_mem_selector}).  The offsets are linear
  1195. offsets.  If the selector is for the program's data area, this offset
  1196. corresponds to the address of a buffer (like @code{(int)&something}).  If the
  1197. selector is for the conventional memory area, the offset is the physical
  1198. address of the memory, which can be computed from a traditional
  1199. segment/offset pair as @code{segment}*16+@code{offset}.  For example,
  1200. the color text screen buffer is at offset 0xb8000. 
  1201.  
  1202. @subheading Return Value
  1203.  
  1204. None.
  1205.  
  1206. @subheading Example
  1207.  
  1208. @example
  1209. short blank_row_buf[ScreenCols()];
  1210. /* scroll screen */
  1211. movedata(_go32_conventional_mem_selector(), 0xb8000 + ScreenCols()*2,
  1212.          _go32_conventional_mem_selector(), 0xb8000,
  1213.          ScreenCols() * (ScreenRows()-1) * 2);
  1214. /* fill last row */
  1215. movedata(_go32_my_ds, (int)blank_row_buf,
  1216.          _go32_conventional_mem_selector(),
  1217.             0xb8000 + ScreenCols()*(ScreenRows()-1)*2,
  1218.           ScreenCols() * 2);
  1219. @end example
  1220.